package com.jn;

import com.jn.config.ApplicationConfig;
import com.jn.entity.User;
import com.jn.services.UserService;
import com.jn.services.imp.TestService;
import com.jn.spring.SpringContextUtil;
import com.jn.util.JsonUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.List;

@SpringBootApplication
public class ApplicationMain {

    public static void main(String[] args) {
        SpringApplication.run(ApplicationConfig.class, args);
        try {
            System.out.println("====================================================");
            run1();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //	@Override
    public static void run(String... strings) throws Exception {
        System.out.println("====================================================");
        UserService us = SpringContextUtil.getBean("userServiceImpl");
        List<User> userList = us.get("");
        System.out.println(JsonUtil.toJsonString(userList));
        System.out.println("*****************************************************");

        int i = 0;

        while (true) {
            Thread.sleep(5 * 1000);

            System.out.println("****" + i++);
            userList = us.get("");
            System.out.println(JsonUtil.toJsonString(userList));
        }
    }



    public static void run1(String... strings) throws Exception {
        System.out.println("====================================================");
        TestService us = SpringContextUtil.getBean("testService");
        us.test1();
        us.test2();
        us.test3();
        us.test4();
        System.out.println("*****************************************************");

        int i = 0;

        while (true) {
            Thread.sleep(5 * 1000);

            System.out.println("####################" + i++);

        }
    }
}
